********************************************************************************************
** The Ukrainian Refugee Crisis and the Politics of Public Opinion: Evidence from Hungary **
********************************************************************************************

********************************
* Replication file, Sections 6 *
********************************

* Authors: Tom Pepinsky; Ádám Reiff; Kriszti Szabó
* Last updated: 22/Jan/2024
*****************************

* Note that for confidentiality reasons, the data file correspoonding to this replication
* file can only be accessed with the permission of the data owner TARKI Zrt.

* Please contact the authors of the article, who will put you in touch with TARKI Zrt.
 
* The dta-files that are used in this section are:
*         omni2204_ceu_EN_withsettldata_workfile.dta
*         omni2211_ceu_EN_withsettldata_workfile.dta

set scheme white_tableau

*************************************************************************************************************************************
**** Table 6: Variance Decomposition and MLM Estimation for Individuals' Attitude about Immigrants by Source Country, April 2022 ****
*************************************************************************************************************************************

* use "...\omni2204_ceu_EN_withsettldata_workfile.dta", clear
*     //  n=1,023, our original survey from April 2022, extended with settlement-level variables

* Panel A
    * "Mean(\alpha_00)":      _cons (estimated constant)
	* "Variance":             sum of var(_cons) and var(Residual)
	* "Between variance (%)": var(_cons) / (var(_cons) + var(Residual))
  * Ukraine
mixed ukrblr100 if m_ukrblrNUM==1 [pw=weight] || ID_merge:, pwscale(effective)
  * Belarus
mixed ukrblr100 if m_ukrblrNUM==2 [pw=weight] || ID_merge:, pwscale(effective)
  * Afghanistan
mixed afgpak100 if m_afgpakNUM==1 [pw=weight] || ID_merge:, pwscale(effective)
  * Pakistan
mixed afgpak100 if m_afgpakNUM==2 [pw=weight] || ID_merge:, pwscale(effective)

* Panel B
    * "Explained between variance": (reduction in var(_cons) relative to Panel A) / (var(_cons) in Panel A)
  * Ukraine
mixed ukrblr100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition i.hh roma age age2 single divorced widowed if m_ukrblrNUM==1 [pw=weight] || ID_merge:, pwscale(effective)
  * Belarus
mixed ukrblr100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition i.hh roma age age2 single divorced widowed if m_ukrblrNUM==2 [pw=weight] || ID_merge:, pwscale(effective)
  * Afghanistan
mixed afgpak100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition ch1 ch2 ch3pl i.hh roma age age2 single divorced widowed if m_afgpakNUM==1 [pw=weight] || ID_merge:, pwscale(effective)
  * Pakistan
mixed afgpak100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition ch1 ch2 ch3pl i.hh roma age age2 single divorced widowed if m_afgpakNUM==2 [pw=weight] || ID_merge:, pwscale(effective)


**********************************************************************************************************************************
* Table 7: Variance Decomposition and MLM Estimation for Individuals' Attitude about Immigrants by Source Country, November 2022 *
**********************************************************************************************************************************

* use "...\omni2211_ceu_EN_withsettldata_workfile.dta", clear
*     //  n=1,000, our original survey from November 2022, extended with settlement-level variables

* Panel A
    * "Mean(\alpha_00)":      Mean
	* "Variance":             sum of var(_cons) and var(Residual)
	* "Between variance (%)": var(_cons) / (var(_cons) + var(Residual))
  * Ukraine
sum ukrblr100 if m_ukrblrNUM==1 [aweight=weight], d
mixed ukrblr100 if m_ukrblrNUM==1 [pw=weight] || ID_merge:, pwscale(effective)
  * Belarus
sum ukrblr100 if m_ukrblrNUM==2 [aweight=weight], d
mixed ukrblr100 if m_ukrblrNUM==2 [pw=weight] || ID_merge:, pwscale(effective)
  * Afghanistan
sum afgpak100 if m_afgpakNUM==1 [aweight=weight], d
mixed afgpak100 if m_afgpakNUM==1 [pw=weight] || ID_merge:, pwscale(effective)
  * Pakistan
sum afgpak100 if m_afgpakNUM==2 [aweight=weight], d
mixed afgpak100 if m_afgpakNUM==2 [pw=weight] || ID_merge:, pwscale(effective)

* Panel B
    * "Explained between variance": (reduction in var(_cons) relative to previos line) / (var(_cons) in previous line)
  * Ukraine
mixed ukrblr100 if m_ukrblrNUM==1 [pw=weight] || ID_merge:, pwscale(size)
mixed ukrblr100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel uncertainrel fidesz opposition i.hh roma age age2 single divorced widowed if m_ukrblrNUM==1 [pw=weight] || ID_merge:, pwscale(size)
  * Belarus
mixed ukrblr100 if m_ukrblrNUM==2 [pw=weight] || ID_merge:, pwscale(size)
mixed ukrblr100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition i.hh roma age age2 single divorced widowed if m_ukrblrNUM==2 [pw=weight] || ID_merge:, pwscale(size)
  * Afghanistan
mixed afgpak100 if m_afgpakNUM==1 [pw=weight] || ID_merge:, pwscale(size)
mixed afgpak100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition ch1 ch2 ch3pl i.hh roma age age2 single divorced widowed if m_afgpakNUM==1 [pw=weight] || ID_merge:, pwscale(size)
  * Pakistan
mixed afgpak100 if m_afgpakNUM==2 [pw=weight] || ID_merge:, pwscale(size)
mixed afgpak100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition ch1 ch2 ch3pl i.hh roma age age2 single divorced widowed if m_afgpakNUM==2 [pw=weight] || ID_merge:, pwscale(size)


****************************************************************************************************************************************************
**** Table 8: Variance Decomposition and MLM Estimation for Individuals' Attitude about Immigrants with Different Ethnic Background, April 2022 ****
****************************************************************************************************************************************************

* use "...\omni2204_ceu_EN_withsettldata_workfile.dta", clear
*     //  n=1,023, our original survey from April 2022, extended with settlement-level variables

* Panel A
    * "Mean(\alpha_00)":      _cons (estimated constant)
	* "Variance":             sum of var(_cons) and var(Residual)
	* "Between variance (%)": var(_cons) / (var(_cons) + var(Residual))
  * Ethnic Hungarians
mixed ethnichun100 [pw=weight] || ID_merge:, pwscale(effective)
  * Germans
mixed german100 [pw=weight] || ID_merge:, pwscale(effective)
  * Arabic
mixed arabic100 [pw=weight] || ID_merge:, pwscale(effective)
  * Russians
mixed russian100 [pw=weight] || ID_merge:, pwscale(effective)
  * Chinese
mixed chinese100 [pw=weight] || ID_merge:, pwscale(effective)
  * Piresians
mixed piresian100 [pw=weight] || ID_merge:, pwscale(effective)
  * Piresistani
mixed piresistan100 [pw=weight] || ID_merge:, pwscale(effective)

* Panel B
    * "Explained between variance": (reduction in var(_cons) relative to Panel A) / (var(_cons) in Panel A)
  * Ethnic Hungarians
mixed ethnichun100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)
  * Germans
mixed german100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)
  * Arabic
mixed arabic100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)
  * Russians
mixed russian100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)
  * Chinese
mixed chinese100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)
  * Piresians
mixed piresian100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)
  * Piresistani
mixed piresistan100 SRB_min christ_sh roma_sh incomepc veryrel slightlyrel uncertainrel fidesz opposition secondary high female roma single divorced widowed [pw=weight] || ID_merge:, pwscale(effective)


*******************************************************************************************************************************************************
**** Table 9: Variance Decomposition and MLM Estimation for Individuals' Attitude about Immigrants with Different Ethnic Background, November 2022 ****
*******************************************************************************************************************************************************

* use "...\omni2211_ceu_EN_withsettldata_workfile.dta", clear
*     //  n=1,000, our original survey from November 2022, extended with settlement-level variables

* Panel A
    * "Mean(\alpha_00)":      Mean
    * "Variance":             sum of var(_cons) and var(Residual)
    * "Between variance (%)": var(_cons) / (var(_cons) + var(Residual))
  * Ethnic Hungarians
sum ethnichun100 [aweight=weight], d
mixed ethnichun100 [pw=weight] || ID_merge:, pwscale(size)
  * Germans
sum german100 [aweight=weight], d
mixed german100 [pw=weight] || ID_merge:, pwscale(size)
  * Arabic
sum arabic100 [aweight=weight], d
mixed arabic100 [pw=weight] || ID_merge:, pwscale(size)
  * Russians
sum russian100 [aweight=weight], d
mixed russian100 [pw=weight] || ID_merge:, pwscale(size)
  * Chinese
sum chinese100 [aweight=weight], d
mixed chinese100 [pw=weight] || ID_merge:, pwscale(size)
  * Piresians
sum piresian100 [aweight=weight], d
mixed piresian100 [pw=weight] || ID_merge:, pwscale(size)
  * Piresistani
sum piresistan100 [aweight=weight], d
mixed piresistan100 [pw=weight] || ID_merge:, pwscale(size)

* Panel B
    * "Explained between variance": (reduction in var(_cons) relative to panel A ) / (var(_cons) in panel A)
  * Ethnic Hungarians
mixed ethnichun100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
  * Germans
mixed german100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
  * Arabic
mixed arabic100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
  * Russians
mixed russian100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
  * Chinese
mixed chinese100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
  * Piresians
mixed piresian100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
  * Piresistani
mixed piresistan100 SRB_min christ_sh roma_sh incomepc FIDsh foreign_sh veryrel slightlyrel fidesz opposition roma single divorced widowed secondary high female [pw=weight] || ID_merge:, pwscale(size)
